package Client;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

import Server.Server;

public class Main {

	public static int count = 0;
	public volatile static ArrayList<Socket> mSocketList = new ArrayList<Socket>();
	public volatile static ArrayList<String> mContactList = new ArrayList<String>();

	public static ArrayList<String> getContactList() {
		synchronized (Main.class) {
			return mContactList;
		}
	}

	public static ArrayList<Socket> getSocketList() {
		synchronized (Main.class) {
			return mSocketList;
		}
	}

	public static void main(String[] args) {
		ServerSocket mServerSocket = null;
		try {
			mServerSocket = new ServerSocket(1233);
		} catch (IOException exception) {
		}
		while (true && mServerSocket != null) {
			System.out.println("Total: " + Main.mContactList.size());
			try {
				Socket socket = mServerSocket.accept();
				Server server = new Server(socket);
				server.start();
				Thread.sleep(1000);
			} catch (IOException ex) {

			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
